package com.zhou.spring.cloud.server.controller;

import com.zhou.common.operator.log.core.annotation.OperateLog;
import com.zhou.common.operator.log.core.constant.OperateActionEnum;
import com.zhou.spring.cloud.server.sercie.UserService;
import com.zhou.spring.cloud.server.sercie.UserServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/test")
public class TestController {


    @Autowired
    private UserServiceImpl userServiceImpl;

    @Autowired
    private UserService userService;

    @OperateLog(action = OperateActionEnum.OPERATION,
            operateInstruction = "测试日志组件",
            operateSystem = "operateSystem",
            operateType = "operateType",
            operateModule = "operateModule"
    )
    @GetMapping("/retry/{param}")
    public String testRetry(@PathVariable String param) {
        return "testRetry" + param;
    }

    @GetMapping("/timeout")
    public String testTimeout() throws InterruptedException {
        Thread.sleep(1000000);
        return "testTimeout";
    }

    @GetMapping("/testException")
    public String testException() {
        if (1 == 1) {
            throw new RuntimeException("test exception");
        }
        return "testException";
    }
}
